Skip to content

feat(profile): versioned KitProfile schema + canonical serialization (Pillar 4 step 1) - #295

Merged
sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a
Jul 9, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Description

First build step of the versioned, traveling project profile (Pillar 4 of the kit 5.0 North Star). Design note: kit-research/docs/research/pillar4-traveling-profile-5.0.md (merged as kit-research #27).

kit's setup-state is today scattered across ≥6 files (.kit.toml, .kit-baseline.json, skills-lock.json, .mcp.json/.claude.json, .kit-policy.*) with nothing binding, versioning, or auditing it as a whole. This PR adds the pure floor — the type, schema, load/save, and a canonical signing/diffing byte form — with no CLI, no discovery, and no drift logic yet (those are later steps). Zero-LLM, deterministic.

Type of Change

  • New feature (non-breaking change that adds functionality)

Related Issues

  • Related to the kit 5.0 North Star, Pillar 4 (traveling project profile)
  • Design: kit-research/docs/research/pillar4-traveling-profile-5.0.md

Changes Made

  • src/profile/schema.ts:
    • KitProfile type declaring {skills, mcp, workflows, plugins, vault, gates, scope} — each section a reference to the scattered setup-state, not a copy of it.
    • .kit-profile.toml load/save via smol-toml; PROFILE_SCHEMA_VERSION = 1 with fail-closed refusal of a newer schema (mirrors .kit-policy.toml's version gate).
    • Zod validation (strict — a signed artifact should reject typos) with a tagged InvalidProfileError so gate paths fail closed with a clean message, exactly like InvalidConfigError for .kit.toml.
    • loadProfile returns null when no profile is declared → callers can skip honestly instead of treating "no profile" as "empty profile".
    • canonicalProfileBytes: recursively key-sorted JSON with the volatile generated stamp excluded — stable across TOML reformatting / key reorder, same discipline as canonicalPolicyBytes. Plus profileFingerprint (sha256:...).
  • src/profile/schema.test.ts: 16 unit tests (parse valid/invalid/version-gate/strict-typo/missing-name; load null/present/fail-closed; save round-trip + stamp; canonical bytes exclude generated, order-independent, move on real change; fingerprint stability).

Testing

Test Coverage

  • Added new tests (16)
  • All tests pass (npm test) — full suite 2620 pass / 0 fail (2604 baseline + 16 new)

Manual Testing

  1. npx tsc --noEmit → clean.
  2. npx eslint src/profile/*.ts → clean.
  3. npm run build && node scripts/test.mjs → 2620 pass, 0 fail.
  4. npx prettier --check src/profile/*.ts → formatted.

Breaking Changes

None / N/A — new module, nothing else imports it yet.

Checklist

  • My code follows the project's style guidelines
  • All new code has test coverage
  • All tests pass locally (npm test)
  • No new warnings or errors introduced
  • No hardcoded secrets or sensitive data — the profile carries backend selection and key names only; plaintext values remain blocked by the .env* write-gate
  • Code has been self-reviewed

Performance Impact

  • No performance impact

Reviewer Notes

Deliberate design choices worth a look: strict Zod (vs. .kit.toml's .passthrough()) — justified because the profile is a fresh 5.0 artifact that will be signed, and within a schema version an unknown key is a typo, not forward-compat (a real new field bumps version, which is refused by older kit). The [scope]/RoE section is declared here but signing (.kit-profile.sig, reusing signWithIdentity/verifyPolicy) and drift reconciliation land in later steps per the design note's incremental plan.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2


Generated by Claude Code

…(Pillar 4 step 1)

The pure floor for the traveling project profile (design:
kit-research/docs/research/pillar4-traveling-profile-5.0.md). Adds src/profile/schema.ts:

- KitProfile type declaring {skills, mcp, workflows, plugins, vault, gates, scope},
  each section a reference to setup-state that lives scattered across .kit.toml /
  .kit-baseline.json / skills-lock.json / .mcp.json / .kit-policy.* today.
- .kit-profile.toml load/save via smol-toml; PROFILE_SCHEMA_VERSION=1 with fail-closed
  refusal of a newer schema, mirroring .kit-policy.toml's version gate.
- Zod validation (strict — catches typos in a signed artifact) with a tagged
  InvalidProfileError so gate paths fail closed with a clean message, like InvalidConfigError.
- loadProfile returns null when no profile is declared (honest skip, not empty profile).
- canonicalProfileBytes: recursively key-sorted JSON with the volatile 'generated' stamp
  excluded — stable signing/diffing bytes, same discipline as canonicalPolicyBytes. Plus
  profileFingerprint (sha256:...).

No CLI, no discovery, no drift yet (later steps). Zero-LLM, deterministic. No secret
values in the profile — backend selection and key names only. 16 unit tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit 5660c20 into main Jul 9, 2026
18 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a branch July 9, 2026 21:44
sandstream added a commit that referenced this pull request Jul 9, 2026
#297)

Wires the profile schema (#295) + drift core (#296) into a CLI verb via COMMAND_REGISTRY
(design: pillar4-traveling-profile-5.0.md). Adds src/commands/profile.ts:

- show   — render the declared profile with per-line reconciliation marks (✓/DRIFT/REMOVED/
           ADDED), fingerprint, and an unaudited note for kinds not yet discoverable.
- freeze — snapshot the DISCOVERED toolchain (skills/mcp via discoverAgentToolchain, vault
           store from .kit.toml) into .kit-profile.toml, PRESERVING operator-authored
           name/workflows/plugins/gates/scope verbatim. Deliberate action, like baseline freeze.
- check  — report declared-vs-discovered drift; --gate turns any drift into a non-zero exit
           for CI (default is warn/exit-0). Honest skip (exit 0) when no profile is declared.

--json on every subcommand. Zero-LLM, deterministic; never auto-mutates the toolchain.
Registry entry (experimental) + SUBCOMMAND_HELP; contracts/public-surface.json regenerated
for the new verb. 7 command tests.


Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants